package come.whvc

object Test4 {
  def main(args: Array[String]): Unit = {
    val messages = List(
      "INFO: job started",
      "WARN: retry stage 2",
      "ERROR:missing column",
      "INFO: job finished"
    )
    val alerts = messages
      .filter(line => line.startsWith("WARN") || line.startsWith("ERROR"))
      .map(line => line.split(":").last.trim.toUpperCase)

    println(alerts)

    val statusRecords = List("spark,success","spark,failure","flink,success")
    val succesProjects = statusRecords
      .filter(record => record.endsWith("success"))
      .map(record => record.split(",", 2).head)

    println(succesProjects)
  }
}
